<?php

use yii\db\Migration;

/**
 * Handles the creation of table `{{%news}}`.
 */
class m250103_020745_create_news_table extends Migration
{

    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('news', [
                'id' => $this->primaryKey(),
                'author_id' => $this->integer()->notNull(),
                'category_id' => $this->integer()->defaultValue(1),
                'title' => $this->string(12)->notNull()->unique(),
                'content' => $this->text(),
        ]);
        $this->createIndex(
            'idx-post-author_id',
            'post',
            'author_id'
        );
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropIndex(
            'idx-post-author_id',
            'post'
        );
        $this->dropTable('news');
    }
}
